﻿using StableDiffusionTools.Interop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StableDiffusionTools.Utils
{
    public static class ControlUtil
    {
        public static void SuspendPaint(this Control control)
        {
            if (!control.IsHandleCreated)
                return;

            User32.SendMessage(control.Handle, WindowMessage.SetRedraw, false, IntPtr.Zero);
        }
        public static void ResumePaint(this Control control, bool invalidateChildren = true)
        {
            if (!control.IsHandleCreated)
                return;

            User32.SendMessage(control.Handle, WindowMessage.SetRedraw, true, IntPtr.Zero);
            control.Invalidate(invalidateChildren);
            control.Update();
        }
    }
}
